import BaseShape2D from "../../src/shapes/BaseShape2D";
import Size from "../../src/geom/Size";
import Vector2 from "../../src/maths/Vector2";
import ITransformable from "../../src/interfaces/ITransformable";
import IRenderState from "../../src/interfaces/IRenderState";

export default class TankShape extends BaseShape2D {
    private _size: Size;
    private _width: number;

    public constructor(size: Size = Size.create(80, 50), turretWidth: number = 100) {
        super();
        this._size = size;
        this._width = turretWidth;
    }

    public hitTest(localPt: Vector2, transform: ITransformable): boolean {
        return false;
    }

    public get type(): string {
        return 'tank';
    }

    public draw(transformable: ITransformable, state: IRenderState, context: CanvasRenderingContext2D): void {
        context.save();
        context.fillRect(-this._size.width * 0.5, -this._size.height * 0.5, this._size.width, this._size.height);
        context.save();
        context.strokeStyle = 'red';
        context.lineWidth = 5;
        context.beginPath();
        context.moveTo(0, 0);
        context.lineTo(this._width, 0);
        context.stroke();
        context.restore();
        context.restore();
    }
}